<?php

include "header.php";
include "./lib/func.php";
include "./lib/config.php";

if (($user = isLogin()) == false){
    header("location:index.php");
}


$redis = connentRedis(Config::REDISHOST, Config::PORT);
$redis->lTrim('recivePost:'. $user['userid'], 0, 49);
$newPost = $redis->sort('recivePost:'. $user['userid'], ['sort'=> 'desc', 'get' => 'post:postid:*:body']);

//计算粉丝和关注数量
$myFans = $redis->sCard('followed:'. $user['userid']);
$myStar = $redis->sCard('following:'. $user['userid']);

?>
<div id="navbar">
<a href="index.php">主页</a>
| <a href="timeline.php">热点</a>
| <a href="logout.php">退出</a>
</div>
</div>
<div id="postform">
<form method="POST" action="post.php">
<?php echo $user['username'] ?>, 有啥感想?
<br>
<table>
<tr><td><textarea cols="70" rows="3" name="status"></textarea></td></tr>
<tr><td align="right"><input type="submit" name="doit" value="发微博"></td></tr>
</table>
</form>
<div id="homeinfobox">
<?php echo $myFans ?> 粉丝<br>
<?php echo $myStar ?> 关注<br>
</div>
</div>
<?php foreach ($newPost as $item){ ?>
<div class="post">
<a class="username" href="profile.php?u=test">test</a> <?php echo $item; ?><br>
<i>11 分钟前 通过 web发布</i>
</div>
<?php }; ?>

<?php include "footer.php"; ?>

